using System;
using System.IO;
using GHIElectronics.NETMF.USBHost;
using System.Threading;

namespace PTP.Usb.GHI
{
  /// <summary>
  /// Stream implementation over two USBH_RawDevice.Pipes. Buffered. Not thread safe.
  /// </summary>
  public class USBH_PipeStream : PipeStream
  {

    public USBH_PipeStream(USBH_RawDevice.Pipe inPipe, USBH_RawDevice.Pipe outPipe) : base(new USBH_PipeWrapper(inPipe), new USBH_PipeWrapper(outPipe))
    {

    }


    protected override int getBufferSize()
    {
      if (((USBH_PipeWrapper)this.inPipe).PacketSize < ((USBH_PipeWrapper)this.outPipe).PacketSize)
        return ((USBH_PipeWrapper)this.outPipe).PacketSize;
      else
        return ((USBH_PipeWrapper)this.inPipe).PacketSize;
    }

  }
}
